

import com.mysql.jdbc.Connection;
import com.mysql.jdbc.PreparedStatement;
import java.sql.DriverManager;
import java.sql.ResultSet;
import javax.swing.*;

class AutoCompleteTest
{
public static void main(String arg[]) {
JFrame fr = new JFrame("Test");
JTextField c = new JTextField();
AutoTextComplete atc = new AutoTextComplete(c);

try {
            String sql1 = "SELECT Invoice FROM test.Selling;";
            Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/chain", "root", "password");
            PreparedStatement ps = (PreparedStatement) con.prepareStatement(sql1);
            ResultSet rs0 = ps.executeQuery();

            while (rs0.next()) {
                atc.setItems(new String[] {rs0.getString("Invoice")});

            }
            con.close();

        } catch (Exception e5) {
            JOptionPane.showMessageDialog(null, "Your database problem");

        }
fr.getContentPane().add(new JScrollPane(c));
fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
fr.pack();
fr.setVisible(true);
}
}
